package gao.xiaolei.dao;

import java.util.List;

import gao.xiaolei.entity.UrlRole;
import gao.xiaolei.entity.UrlRoleId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository("UrlRoleDao")
public interface UrlRoleDao extends JpaRepository<UrlRole, UrlRoleId> {

	@Query(value = "select id.url_id from UrlRole where id.role_id= :roleId")
	public List<String> queryUrlByRoleId(@Param("roleId") String roleId);

	@Query(value = "select id.role_id from UrlRole where id.url_id= :urlId")
	public List<String> queryRoleByUrlId(@Param("urlId") String urlId);
	
	@Modifying
	@Query(value="delete UrlRole where id.role_id= :id")
	public void deleteByRoleId(@Param("id") String id);
	
	@Modifying
	@Query(value="delete UrlRole where id.url_id= :id")
	public void deleteByUrlId(@Param("id") String id);
}
